<?php 
$sql = "SELECT `Less than $10,000` , `$10,000 to $14,999` , `$15,000 to $24,999` , `$25,000 to $34,999` , `$35,000 to $49,999` , `$50,000 to $74,999` , `$75,000 to $99,999` , `$100,000 to $149,999` , `$150,000 to $199,999` , `$200,000 or More` , `Households` FROM `ZipCode Profile3` WHERE `ZCTA5` = $zipcode";
		
$result = mysql_query($sql,$db);
$numrows = mysql_num_rows($result);
while ($row = mysql_fetch_array($result,MYSQL_NUM))
{
			  	  $LTthirtyfivek = $row[0] + $row[1] + $row[2] + $row[3];
				  $thirtyfivektoseventyfivek = $row[4] + $row[5];
				  $seventyfivektoonefiftyk = $row[6] + $row[7];
				  $onefiftykandmore = $row[8] + $row[9];
				  $total_household = $row[10];
}

if($total_household != 0)
{
$LTthirtyfivek_percet = number_format((100*$LTthirtyfivek)/$total_household,2);
$thirtyfivektoseventyfivek_percet = number_format((100*$thirtyfivektoseventyfivek)/$total_household,2);
$seventyfivektoonefiftyk_percet = number_format((100*$seventyfivektoonefiftyk)/$total_household,2);
$onefiftykandmore_percet = number_format((100*$onefiftykandmore)/$total_household,2);

echo "<Table width=250px cellspacing='-1' bordar=0>";
	   echo "<tr style='width:100%; background:#F5DEB3; font-size:12px'>";
	  echo "<td >Total Households: ";
	  echo "</td>";
	  echo "<td align='right' nowrap='nowrap'>".$total_pop;
	  echo "</td>";
	  
      echo "<tr style='width:100%; font-size:12px'>";
	  echo "<td>Less than $35,000: ";
	  echo "</td>";
	  echo "<td align='right' nowrap='nowrap'>".$LTthirtyfivek." (".$LTthirtyfivek_percet."%)";
	  echo "</td>";
	  echo "</tr>";
	  
	  echo "<tr style='width:100%; background:#F5DEB3;  font-size:12px'>";
	  echo "<td>$35,000 to $74,000: ";
	  echo "</td>";
	  echo "<td align='right' nowrap='nowrap'>".$thirtyfivektoseventyfivek." (".$thirtyfivektoseventyfivek_percet."%)";
	  echo "</td>";
	  echo "</tr>";
	  
      echo "<tr style='width:100%; font-size:12px'>";
	  echo "<td>$75,000 to $149,999: ";
	  echo "</td>";
	  echo "<td align='right' nowrap='nowrap'>".$seventyfivektoonefiftyk." (".$seventyfivektoonefiftyk_percet."%)";
	  echo "</td>";
	  echo "</tr>";
	  
	  echo "<tr style='width:100%; background:#F5DEB3;  font-size:12px'>";
	  echo "<td>$150,000 or more: ";
	  echo "</td>";
	  echo "<td align='right' nowrap='nowrap'>".$onefiftykandmore." (".$onefiftykandmore_percet."%)";
	  echo "</td>";
	  echo "</tr>";
	  
echo "</Table>";
}
else
{
if($numrows == 0)
{
$nodata_msg = "Data is not available.  Please make sure the City, State and Zipcode Information is correct.";
}
else
{
$nodata_msg = "Data is not available for this Zipcode.";
}

echo "<Table width=250px cellspacing='-1' bordar=0>";
      echo "<tr style='width:100%; background:#F5DEB3; font-size:12px'>";
	  echo "<td align='right' nowrap='nowrap'>".$nodata_msg;
	  echo "</td>";

	  echo "</Table>";


}
?>
